use "data\influenza_town_panel.dta",replace

gen year_bi=year
replace year_bi=1910 if year==1911
replace year_bi=1912 if year==1913
replace year_bi=1914 if year==1915
replace year_bi=1916 if year==1917
replace year_bi=1918 if year==1919
replace year_bi=1920 if year==1921
replace year_bi=1922 if year==1923
replace year_bi=1924 if year==1925

tab year_bi, gen(d_year_bi)
forvalues i=1/8 {
gen d_year_bi`i'_treat=indian_dm1918*d_year_bi`i'
}

reghdfe log_deaths_town   d_year_bi2_treat-d_year_bi8_treat , vce(cluster  did) absorb(  cid  year)

regsave, ci
gen n=[_n]
set obs 8
replace coef = 0 in 8
replace ci_lower = 0 in 8
replace ci_upper = 0 in 8
replace n = 0 in 8

sort n

replace n=1910 if n==0
replace n=1912 if n==1
replace n=1914 if n==2
replace n=1916 if n==3
replace n=1918 if n==4
replace n=1920 if n==5
replace n=1922 if n==6
replace n=1924 if n==7

twoway (connected coef n) (rcap ci_lower ci_upper n), scheme(s2mono) graphregion(color(white)) xtitle("") ytitle("Log total deaths - Indian vs. British DO") legend(off)  xline(1917)  xlabel(1910(2)1924)
graph export "output\figure2.pdf", as(pdf) replace
